<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<h:head>
	<h:outputStylesheet name="global.css" library="css" />
	<h:outputScript name="global.js" library="javascript"/>
	<h:outputScript name="validacao.js" library="javascript"/>
	<h:outputScript name="restricoes_de_campos.js" library="javascript"/>
</h:head>

<h:body>
	<h1>Tabela Taxas</h1>

	<div class="form_title">
		<span class="active"><h:outputText
				value="Tabela de taxas e comissões" /></span>
	</div>
	
	<h:form id="form">
		<p:messages id="messages" />
		<p:focus/>

		<p:panelGrid styleClass="panelGridCenter gridNoBackground noBorders">

			<p:row>
				<p:column styleClass="columnRight">
					<p:outputLabel value="Código"/>
				</p:column>

				<p:column colspan="3">
					<p:inputText label="Código"
						value="#{tabelaTaxaBean.pojo.id}" disabled="true"
						rendered="#{tabelaTaxaBean.pojo.id != null}" size="15" />
				</p:column>
			</p:row>
			
			<p:row>
				<p:column styleClass="columnRight">
					<p:outputLabel value="Nome" />
				</p:column>

				<p:column colspan="3">
					<p:inputText label="Nome" value="#{tabelaTaxaBean.pojo.nome}"
						required="true" maxlength="30" size="35"/>
				</p:column>
			</p:row>

			<p:row>
				<p:column styleClass="columnRight">
					<p:outputLabel value="Desativada" />
				</p:column>
				
				<p:column colspan="3">
					<p:selectBooleanCheckbox
						label="Desativada"
						value="#{tabelaTaxaBean.pojo.desativada}" />
				</p:column>						
			</p:row>

			<p:row>
				<p:column styleClass="columnRight">
					<p:outputLabel
						value="Tabela não pode ser vinculada às lojas" />
				</p:column>
				
				<p:column>
					<p:selectBooleanCheckbox
						label="Tabela não pode ser vinculada às lojas"
						value="#{tabelaTaxaBean.pojo.tabelaNaoPodeSerVinculadaLojas}" />
				</p:column>						
			
				<p:column styleClass="columnRight">
					<p:outputLabel value="Ano de fabricação do veículo" />
				</p:column>

				<p:column>
					<p:inputText id="anoFabInicial"
						label="Ano de fabricação do veículo inicial"
						value="#{tabelaTaxaBean.pojo.anoFabricacaoVeiculoMin}"
						required="#{tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}"
						maxlength="4" size="9" onkeypress="mascara(this, soNumeros)"
						disabled="#{!tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}" />

					<p:outputLabel value=" a "/>

					<p:inputText id="anoFabFinal"
						label="Ano de fabricação do veículo final"
						value="#{tabelaTaxaBean.pojo.anoFabricacaoVeiculoMax}"
						required="#{tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}"
						maxlength="4" size="9" onkeypress="mascara(this, soNumeros)"
						disabled="#{!tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}" />
				</p:column>
			</p:row>

			<p:row>
				<p:column styleClass="columnRight">
					<p:outputLabel value="Tabela exclusiva para C.P. garantia" />
				</p:column>
				
				<p:column>
					<p:selectBooleanCheckbox
						label="Tabela exclusiva para C.P. garantia"
						value="#{tabelaTaxaBean.pojo.tabelaExclusivaParaCPGarantia}" />
				</p:column>						
			
				<p:column styleClass="columnRight">
					<p:outputLabel value="Financiamento permitido sobre o valor do veículo" />
				</p:column>

				<p:column>
					<p:inputText id="financiamento"
						label="Financiamento permitido sobre o valor do veículo"
						value="#{tabelaTaxaBean.pojo.financiamentoPermitidoSobreValorVeiculo}"
						required="#{tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}"
						maxlength="11" size="16" onkeypress="mascara(this, soNumeros)"
						disabled="#{!tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}"> 
							<f:convertNumber locale="pt_BR" minFractionDigits="2" maxFractionDigits="2" />
					</p:inputText>

					<p:outputLabel value=" %"/>
				</p:column>
			</p:row>

			<p:row>
				<p:column styleClass="columnRight">
					<p:outputLabel value="Tabela utilizada para financiamento de veículos" />
				</p:column>
				
				<p:column>
					<p:selectBooleanCheckbox
						label="Tabela utilizada para financiamento de veículos"
						value="#{tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}">
						<p:ajax update="anoFabInicial anoFabFinal financiamento endividamento" />
					</p:selectBooleanCheckbox>
				</p:column>						
			
				<p:column styleClass="columnRight">
					<p:outputLabel value="Endividamento permitido sobre a renda" />
				</p:column>

				<p:column>
					<p:inputText id="endividamento"
						label="Endividamento permitido sobre a renda"
						value="#{tabelaTaxaBean.pojo.endividamentoPermitidoSobreRenda}"
						required="#{tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}"
						maxlength="11" size="16" onkeypress="mascara(this, soNumeros)"
						disabled="#{!tabelaTaxaBean.pojo.tabelaUtilizadaParaFinanciamentoVeiculos}">
							<f:convertNumber locale="pt_BR" minFractionDigits="2" maxFractionDigits="2" />
					</p:inputText>

					<p:outputLabel value=" %"/>
				</p:column>
			</p:row>

		</p:panelGrid>
		
		<br /> <br />
		
		<div class="form_title">
			<span class="active"><h:outputText value="Taxas e comissão vigentes"/></span>
		</div>
		
		<p:outputPanel id="vigenciaPanel">
			<div style="margin: 0 auto; width: 60%">
				<p:dataTable id="tabelaVigenciaCorrente" editable="true"
					value="#{tabelaTaxaBean.pojo.vigenciaCorrente.faixas}"
					emptyMessage="Adicione pelo menos uma faixa" var="corrente" rowKey="#{corrente}"
					sortBy="prazoMinimo">
					
					<p:ajax event="rowEditInit" oncomplete="btnExcluirCorrente#{corrente.id}.disable();"/>
					<p:ajax event="rowEdit" update=":form:messages" oncomplete="if (!args.validationFailed) btnExcluirFaixaCorrente.enable();"/>
					<p:ajax event="rowEditCancel" oncomplete="btnExcluirFaixaCorrente.enable();"/>
					
					<p:ajax event="page" oncomplete="alert('page')"/>
					<p:ajax event="sort" oncomplete="alert('sort')"/>
					<p:ajax event="filter" oncomplete="alert('filter')"/>
					<p:ajax event="rowSelect" oncomplete="alert('rowSelect')"/>
					<p:ajax event="rowUnselect" oncomplete="alert('rowUnselect')"/>
					<p:ajax event="rowEdit" oncomplete="alert(#{corrente.id})"/>
					<p:ajax event="rowEditInit" oncomplete="alert('#{corrente}')"/>
					<p:ajax event="rowEditCancel" oncomplete="alert('rowEditCancel')"/>
					<p:ajax event="colResize" oncomplete="alert('colResize')"/>
					<p:ajax event="toggleSelect" oncomplete="alert('toggleSelect')"/>
					<p:ajax event="colReorder" oncomplete="alert('colReorder')"/>
					<p:ajax event="rowSelectRadio" oncomplete="alert('rowSelectRadio')"/>
					<p:ajax event="rowSelectCheckbox" oncomplete="alert('rowSelectCheckbox')"/>
					<p:ajax event="rowUnselectCheckbox" oncomplete="alert('rowUnselectCheckbox')"/>
					<p:ajax event="rowDblselect" oncomplete="alert('rowDblselect')"/>
					<p:ajax event="rowToggle" oncomplete="alert('rowToggle')"/>
					<p:ajax event="contextMenu" oncomplete="alert('contextMenu')"/>
					<p:ajax event="cellEdit" oncomplete="alert('cellEdit')"/>
	
					<f:facet name="header">
						<div align="left">
							<p:outputLabel value="#{tabelaTaxaBean.cabecalhoVigenciaCorrente}" />
						</div>
					</f:facet>
					
					<p:column headerText="Prazo (em meses)" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel
									value="#{corrente.prazoMinimo} a #{corrente.prazoMaximo}" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Prazo inicial"
									value="#{corrente.prazoMinimo}" size="8" maxlength="3"
									onkeypress="mascara(this, soNumeros)" required="true" />
								&nbsp;&nbsp;
								<p:inputText label="Prazo final" value="#{corrente.prazoMaximo}"
									size="8" maxlength="3" onkeypress="mascara(this, soNumeros)"
									required="true" />
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Taxa de juros" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{corrente.taxaJuros}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
								<p:outputLabel value="%" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Taxa de juros" value="#{corrente.taxaJuros}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6" required="true">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Taxa diferenciada para o banco/empresa" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{corrente.taxaDiferenciadaParaBanco}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
								<p:outputLabel
									value="#{corrente.taxaDiferenciadaParaBanco == null ? '' : '%'}" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Taxa diferenciada para o banco/empresa"
									value="#{corrente.taxaDiferenciadaParaBanco}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Comissão" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{corrente.comissao}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
	
								<p:outputLabel value="%" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Comissão" value="#{corrente.comissao}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6" required="true">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Complemento" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{corrente.complementoComissao}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
	
								<p:outputLabel
									value="#{corrente.complementoComissao == null ? '' : '%'}" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Complemento"
									value="#{corrente.complementoComissao}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Ação" styleClass="coluna-acao">
						<p:rowEditor/>
						&nbsp;
						<p:commandButton widgetVar="btnExcluirCorrente#{corrente.id}" process="@this" disabled="false"
							styleClass="botaoImagem" icon="botaoExcluir" title="Excluir"
							oncomplete="confirmationFaixaExclusao.show()">
							<f:setPropertyActionListener
								target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
							<f:setPropertyActionListener target="#{tabelaTaxaBean.faixa}"
								value="#{corrente}" />
						</p:commandButton>
					</p:column>
	
					<f:facet name="footer">
						<div align="right">
							<p:commandButton
								disabled="#{tabelaTaxaBean.pojo.vigenciaCorrente == null}"
								process="@this" value="Adicionar faixa"
								update=":dialogAdicionarFaixa" oncomplete="dlgFaixa.show();"
								action="#{tabelaTaxaBean.criarFaixa}" >
								<f:setPropertyActionListener
									target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
							</p:commandButton>
							&nbsp;&nbsp;
							<p:commandButton process="@this" update=":dialogVigencia"
								oncomplete="dlgVigencia.show()" value="Editar vigência"
								action="#{tabelaTaxaBean.editarVigencia}"
								disabled="#{(tabelaTaxaBean.pojo.vigenciaCorrente == null) || (tabelaTaxaBean.pojo.vigenciaProxima != null)}" >
								<f:setPropertyActionListener
									target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
							</p:commandButton>
							&nbsp;&nbsp;
							<p:commandButton process="@this" update=":dialogVigencia"
								oncomplete="confirmationVigenciaExclusao.show()"
								value="Excluir vigência"
								disabled="#{(tabelaTaxaBean.pojo.vigenciaCorrente == null) || (tabelaTaxaBean.pojo.vigenciaProxima != null)}">
								<f:setPropertyActionListener
									target="#{tabelaTaxaBean.vigenciaTipo}" value="corrente" />
							</p:commandButton>
						</div>
					</f:facet>
				</p:dataTable>
		
				<h:panelGroup rendered="#{tabelaTaxaBean.pojo.vigenciaProxima != null}">
					
					<br /> <br />
					
				<p:dataTable id="tabelaVigenciaProxima" editable="true"
					value="#{tabelaTaxaBean.pojo.vigenciaProxima.faixas}"
					emptyMessage="Adicione pelo menos uma faixa" var="proxima" 
					sortBy="prazoMinimo">
					
					<p:ajax event="rowEditInit" oncomplete="disableDataTableButtonExcluir();"/>
					<p:ajax event="rowEdit" update=":form:messages" oncomplete="enableDataTableButtonExcluir();"/>
					<p:ajax event="rowEditCancel" oncomplete="enableDataTableButtonExcluir();"/>
	
					<f:facet name="header">
						<div align="left">
							<p:outputLabel value="#{tabelaTaxaBean.cabecalhoVigenciaProxima}" />
						</div>
					</f:facet>
					
					<p:column headerText="Prazo (em meses)" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel
									value="#{proxima.prazoMinimo} a #{proxima.prazoMaximo}" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Prazo inicial"
									value="#{proxima.prazoMinimo}" size="8" maxlength="3"
									onkeypress="mascara(this, soNumeros)" required="true" />
								&nbsp;&nbsp;
								<p:inputText label="Prazo final" value="#{proxima.prazoMaximo}"
									size="8" maxlength="3" onkeypress="mascara(this, soNumeros)"
									required="true" />
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Taxa de juros" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{proxima.taxaJuros}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
								<p:outputLabel value="%" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Taxa de juros" value="#{proxima.taxaJuros}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6" required="true">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Taxa diferenciada para o banco/empresa" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{proxima.taxaDiferenciadaParaBanco}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
								<p:outputLabel
									value="#{proxima.taxaDiferenciadaParaBanco == null ? '' : '%'}" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Taxa diferenciada para o banco/empresa"
									value="#{proxima.taxaDiferenciadaParaBanco}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Comissão" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{proxima.comissao}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
	
								<p:outputLabel value="%" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Comissão" value="#{proxima.comissao}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6" required="true">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Complemento" styleClass="columnRight">
						<p:cellEditor>
							<f:facet name="output">
								<p:outputLabel value="#{proxima.complementoComissao}">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:outputLabel>
	
								<p:outputLabel
									value="#{proxima.complementoComissao == null ? '' : '%'}" />
							</f:facet>
	
							<f:facet name="input">
								<p:inputText label="Complemento"
									value="#{proxima.complementoComissao}"
									onkeypress="mascara(this,valorMonetario)" size="11"
									maxlength="6">
									<f:convertNumber locale="pt_BR" minFractionDigits="2"
										maxFractionDigits="2" />
								</p:inputText>
							</f:facet>
						</p:cellEditor>
					</p:column>
	
					<p:column headerText="Ação" styleClass="coluna-acao">
						<p:rowEditor/>
						&nbsp;
						<p:commandButton id="btnExcluirFaixaProxima" process="@this" disabled="false"
							styleClass="botaoImagem" icon="botaoExcluir" title="Excluir"
							oncomplete="confirmationFaixaExclusao.show()">
							<f:setPropertyActionListener
								target="#{tabelaTaxaBean.vigenciaTipo}" value="proxima" />
							<f:setPropertyActionListener target="#{tabelaTaxaBean.faixa}"
								value="#{proxima}" />
						</p:commandButton>
					</p:column>
	
					<f:facet name="footer">
						<div align="right">
							<p:commandButton
								process="@this" value="Adicionar faixa"
								update=":dialogAdicionarFaixa" oncomplete="dlgFaixa.show();"
								action="#{tabelaTaxaBean.criarFaixa}" >
								<f:setPropertyActionListener
									target="#{tabelaTaxaBean.vigenciaTipo}" value="proxima" />
							</p:commandButton>
							&nbsp;&nbsp;
							<p:commandButton process="@this" update=":dialogVigencia"
								oncomplete="dlgVigencia.show()" value="Editar vigência"
								action="#{tabelaTaxaBean.editarVigencia}" >
								<f:setPropertyActionListener
									target="#{tabelaTaxaBean.vigenciaTipo}" value="proxima" />
							</p:commandButton>
							&nbsp;&nbsp;
							<p:commandButton process="@this" update=":dialogVigencia"
								oncomplete="confirmationVigenciaExclusao.show()"
								value="Excluir vigência" >
								<f:setPropertyActionListener
									target="#{tabelaTaxaBean.vigenciaTipo}" value="proxima" />
							</p:commandButton>
						</div>
					</f:facet>
				</p:dataTable>

				</h:panelGroup>
		
				<br />
		
				<div align="right">
					<p:commandButton id="btnAdicionarNovaVigencia" process="@this" update=":dialogVigencia"
						actionListener="#{tabelaTaxaBean.criarVigencia()}"
						value="Adicionar vigência" oncomplete="dlgVigencia.show()"
						disabled="#{tabelaTaxaBean.pojo.vigenciaProxima != null}" />
					&nbsp;&nbsp;
					<!-- Arrumar botão de histórico -->
					<p:commandButton type="button" value="Histórico das vigências" />
				</div>
			</div>
		</p:outputPanel>
			
		<div class="form_title" />
			
		<br />
		
		<div align="center">
			<p:commandButton id="salvar" type="Submit" value="Salvar"
				action="#{tabelaTaxaBean.save}" update="messages @parent"
				oncomplete="window.scrollTo(0, 0);" />
			&nbsp;&nbsp;
			<p:commandButton type="button" value="Cancelar"
				onclick="cancelConfirmationForm.show()" />
		</div>

	</h:form>

	<p:dialog id="dialogVigencia" header="#{tabelaTaxaBean.vigencia.id == null ? 'Adicionar' : 'Editar'} vigência"
		widgetVar="dlgVigencia" resizable="false" modal="true" closable="false">
		<h:form id="vigenciaForm">
			<p:messages id="messagesAdicionar" />
			
			<div class="form_title">
				<span class="active"><h:outputText
						value="#{tabelaTaxaBean.vigencia.id == null ? 'Adicionar' : 'Editar'} vigência" /></span>
			</div>
			
			<p:panelGrid id="gridVigencia"
				styleClass="panelGridCenter gridNoBackground noBorders">
				<p:row>
					<p:column styleClass="columnRight">
						<p:outputLabel value="Vigência inicial" />
					</p:column>

					<p:column>
						<p:calendar label="Vigência inicial"
							value="#{tabelaTaxaBean.vigencia.dataInicial}" pattern="dd-MM-yyyy"
							required="true" locale="pt_BR" size="16"/>
					</p:column>
				</p:row>

				<p:row rendered="#{tabelaTaxaBean.vigencia.dataFinal != null and tabelaTaxaBean.vigencia.id != null}">
					<p:column styleClass="columnRight">
						<p:outputLabel value="Vigência final" />
					</p:column>

					<p:column>
						<p:calendar label="Vigência final"
							value="#{tabelaTaxaBean.vigencia.dataFinal}" pattern="dd-MM-yyyy"
							disabled="true" locale="pt_BR" size="16"/>
					</p:column>
				</p:row>
			</p:panelGrid>

			<div align="right">
				<p:commandButton process="vigenciaForm" value="Confirmar"
					oncomplete="if (!args.validationFailed) dlgVigencia.hide()"
					actionListener="#{tabelaTaxaBean.salvarVigencia()}"
					update=":form:vigenciaPanel messagesAdicionar gridVigencia @parent :form:btnAdicionarNovaVigencia" />
				&nbsp;&nbsp;
				<p:commandButton type="button" value="Cancelar"
					onclick="confirmDialogCancelViagencia.show()" />
			</div>
		</h:form>
	</p:dialog>

	<p:confirmDialog message="Deseja realmente cancelar?"
		header="Confirmação de cancelamento" severity="alert"
		widgetVar="confirmDialogCancelViagencia">
		<p:commandButton process="@this" value="Sim"
			update=":form:vigenciaPanel"
			onclick="dlgVigencia.hide(), confirmDialogCancelViagencia.hide()">
			<p:ajax event="click" listener="#{tabelaTaxaBean.resetDialog(':dialogVigencia')}" />
		</p:commandButton>

		<p:commandButton type="button" value="Não"
			onclick="confirmDialogCancelViagencia.hide()" />
	</p:confirmDialog>

	<p:confirmDialog showEffect="false"
		message="Deseja realmente excluir esta vigência?"
		header="Confirmação de exclusão"
		widgetVar="confirmationVigenciaExclusao">
		<p:commandButton process="@this" value="Sim"
			actionListener="#{tabelaTaxaBean.removerVigencia()}"
			oncomplete="confirmationVigenciaExclusao.hide(); window.scrollTo(0, 0);"
			update=":form:vigenciaPanel :form:messages" />
			
		<p:commandButton type="button" value="Não"
			onclick="confirmationVigenciaExclusao.hide()" />
	</p:confirmDialog>

	<p:dialog id="dialogAdicionarFaixa" header="Adicionar faixa"
		widgetVar="dlgFaixa" resizable="false" modal="true" closable="false">
		<h:form id="faixaForm">
			<p:messages id="messagesAdicionar" />

			<div class="form_title">
				<span class="active"><h:outputText value="Adicionar faixa" /></span>
			</div>

			<p:panelGrid id="gridFaixa"
				styleClass="panelGridCenter gridNoBackground noBorders">
				<p:row>
					<p:column styleClass="columnRight">
						<p:outputLabel value="Prazo" />
					</p:column>

					<p:column>
						<p:inputText label="Prazo inicial"
							value="#{tabelaTaxaBean.faixa.prazoMinimo}" size="8"
							maxlength="3" onkeypress="mascara(this, soNumeros)"
							required="true" />
					</p:column>

					<p:column styleClass="noPadding">
						<p:outputLabel value="a" />
					</p:column>

					<p:column>
						<p:inputText label="Prazo final"
							value="#{tabelaTaxaBean.faixa.prazoMaximo}" size="8"
							maxlength="3" onkeypress="mascara(this, soNumeros)"
							required="true" />
					</p:column>

					<p:column styleClass="noPadding">
						<p:outputLabel value="meses" />
					</p:column>

					<p:column>
						<p:graphicImage url="#{resource['images:help-icon.png']}"
							title="Para prazo simples, informe somente o prazo inicial." />
					</p:column>
				</p:row>

				<p:row>
					<p:column styleClass="columnRight">
						<p:outputLabel value="Taxa de juros" />
					</p:column>

					<p:column>
						<p:inputText label="Taxa de juros"
							value="#{tabelaTaxaBean.faixa.taxaJuros}"
							onkeypress="mascara(this,valorMonetario)" size="11" maxlength="6"
							required="true">
							<f:convertNumber locale="pt_BR" minFractionDigits="2"
								maxFractionDigits="2" />
						</p:inputText>
					</p:column>

					<p:column styleClass="noPadding" colspan="4">
						<p:outputLabel value="%" />
					</p:column>
				</p:row>

				<p:row>
					<p:column styleClass="columnRight">
						<p:outputLabel value="Taxa diferenciada para o banco/empresa" />
					</p:column>

					<p:column>
						<p:inputText label="Taxa diferenciada para o banco/empresa"
							value="#{tabelaTaxaBean.faixa.taxaDiferenciadaParaBanco}"
							onkeypress="mascara(this,valorMonetario)" size="11" maxlength="6">
							<f:convertNumber locale="pt_BR" minFractionDigits="2"
								maxFractionDigits="2" />
						</p:inputText>
					</p:column>

					<p:column styleClass="noPadding" colspan="4">
						<p:outputLabel value="%" />
					</p:column>
				</p:row>

				<p:row>
					<p:column styleClass="columnRight">
						<p:outputLabel value="Comissão" />
					</p:column>

					<p:column>
						<p:inputText label="Comissão"
							value="#{tabelaTaxaBean.faixa.comissao}"
							onkeypress="mascara(this,valorMonetario)" size="11" maxlength="6"
							required="true">
							<f:convertNumber locale="pt_BR" minFractionDigits="2"
								maxFractionDigits="2" />
						</p:inputText>
					</p:column>

					<p:column styleClass="noPadding" colspan="4">
						<p:outputLabel value="%" />
					</p:column>
				</p:row>

				<p:row>
					<p:column styleClass="columnRight">
						<p:outputLabel value="Complemento" />
					</p:column>

					<p:column>
						<p:inputText label="Complemento"
							value="#{tabelaTaxaBean.faixa.complementoComissao}"
							onkeypress="mascara(this,valorMonetario)" size="11" maxlength="6">
							<f:convertNumber locale="pt_BR" minFractionDigits="2"
								maxFractionDigits="2" />
						</p:inputText>
					</p:column>

					<p:column styleClass="noPadding" colspan="4">
						<p:outputLabel value="%" />
					</p:column>
				</p:row>
			</p:panelGrid>

			<div class="form_title" />

			<div align="right">
				<p:commandButton process="faixaForm" value="Confirmar"
					oncomplete="if (!args.validationFailed) dlgFaixa.hide()"
					update=":form:vigenciaPanel messagesAdicionar gridFaixa @parent">
					<p:collector addTo="#{tabelaTaxaBean.getTipoFaixa()}"
						value="#{tabelaTaxaBean.faixa}" />
				</p:commandButton>
				&nbsp;&nbsp;
				<p:commandButton type="button" value="Cancelar"
					onclick="confirmDialogCancelFaixa.show()" />
			</div>
		</h:form>
	</p:dialog>

	<p:confirmDialog message="Deseja realmente cancelar?"
		header="Confirmação de cancelamento" severity="alert"
		widgetVar="confirmDialogCancelFaixa">
		<p:commandButton process="@this" type="button" value="Sim"
			onclick="dlgFaixa.hide(), confirmDialogCancelFaixa.hide()">
			<p:ajax event="click" listener="#{tabelaTaxaBean.resetDialog(':dialogAdicionarFaixa')}" />
		</p:commandButton>

		<p:commandButton type="button" value="Não"
			onclick="confirmDialogCancelFaixa.hide()" />
	</p:confirmDialog>

	<p:confirmDialog showEffect="false"
		message="Deseja realmente excluir esta faixa de vigência?"
		header="Confirmação de exclusão" widgetVar="confirmationFaixaExclusao">
		<p:commandButton process="@this" value="Sim"
			oncomplete="confirmationFaixaExclusao.hide(); window.scrollTo(0, 0);"
			update=":form:vigenciaPanel :form:messages">
			<p:collector removeFrom="#{tabelaTaxaBean.getTipoFaixa()}"
				value="#{tabelaTaxaBean.faixa}" />
		</p:commandButton>

		<p:commandButton type="button" value="Não"
			onclick="confirmationFaixaExclusao.hide()" />
	</p:confirmDialog>

	<p:dialog header="Histórico da tabela" widgetVar="dlgLog" resizable="false" modal="true" height="500" width="1000" dynamic="true">
		<!--<ui:include src="#{tabelaTaxaBean.viewLog}" />-->
	</p:dialog>

	<p:confirmDialog id="confirmDialogCancelForm"
		message="Deseja realmente cancelar?"
		header="Confirmação de cancelamento" severity="alert"
		widgetVar="cancelConfirmationForm">

		<p:commandButton process="confirmDialogCancelForm"
			value="Sim" action="#{tabelaTaxaBean.cancelar}"
			oncomplete="cancelConfirmationForm.hide()" />

		<p:commandButton type="button" value="Não"
			onclick="cancelConfirmationForm.hide()" />
	</p:confirmDialog>
</h:body>
</html>
